set(KMPKG_POLICY_ALLOW_RESTRICTED_HEADERS enabled)

# Requirements from https://github.com/besser82/libxcrypt?tab=readme-ov-file#build-requirements-and-instructions
message(
"${PORT} currently requires the following libraries from the system package manager:
    autoconf automake libtool pkg-config
These can be installed on Debian systems via sudo apt install autoconf automake libtool pkg-config"
)
find_program(AUTORECONF_BIN autoreconf)
if(NOT AUTORECONF_BIN)
    message(FATAL_ERROR "${PORT} requires autoconf from the system package manager (example: \"sudo apt install autoconf\")")
endif()
find_program(LIBTOOL_BIN libtoolize)
if(NOT LIBTOOL_BIN)
    message(FATAL_ERROR "${PORT} requires libtool from the system package manager (example: \"sudo apt install libtool\")")
endif()

kmpkg_from_gitee(
    OUT_SOURCE_PATH SOURCE_PATH
    REPO kumo-hub/libxcrypt
    REF "v${VERSION}"
    SHA512 6de17d3769775852084b66585cc26a1f85505ce15652042e7dd5cea56cfa0811c89bab42cbcb5b0a1cb5fc3b0b59f77ccbdcf0a077c4a9d3d6afc02b024b9285
)

kmpkg_configure_make(
    SOURCE_PATH "${SOURCE_PATH}"
    AUTOCONFIG
)

kmpkg_install_make()
kmpkg_fixup_pkgconfig()

kmpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSING" "${SOURCE_PATH}/COPYING.LIB")

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
